package OOPAndMultiThreadArchiveManager.Server.Entities;

import com.fasterxml.jackson.annotation.JsonIgnore;

import java.util.regex.Pattern;

public class UserInfo {
    public String user;

    public String password;

    public String role;

    public UserInfo(String user, String password, String role) {
        this.user = user;
        this.password = password;
        this.role = role;
    }

    public UserInfo() {
    }

    @JsonIgnore
    public boolean isValid() {
        var regex = Pattern.compile("^[a-zA-Z\\d._]{1,128}$");
        return regex.matcher(user).matches() && regex.matcher(password).matches() && (role.equals("Administrator") || role.equals("Browser") || role.equals("Operator"));
    }
}
